USE [HomestayWebDB]
GO
/****** Object:  StoredProcedure [dbo].[Store_Post_ViewWishListOfUser]    Script Date: 11/30/2012 12:14:09 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/* If user is ban or delete, so they cannot login to use function View WistList
Then don't need to check user status
*/
ALTER PROCEDURE [dbo].[Store_Post_ViewWishListOfUser]
	@Username varchar(20)
	
AS
BEGIN
	SELECT DISTINCT
		w.PostID, 
		p.Title as PosTitle, 
		w.TimeCreated, 
		p.PostAvatar , 
		p.PostStatus,
		h.PricePerDay,
		h.PricePerWeek,
		h.PricePerMonth,
		r1.Name as Privince, 
		r2.Name as District
	FROM Wishlists w, Posts p, Images i,Houses h, 
		Houses h1 LEFT JOIN Regions r1 ON h1.Province = r1.RegionID 
				  LEFT JOIN Regions r2 ON h1.District = r2.RegionID 
	WHERE w.Username = @Username and w.PostID = p.PostID 
		  and p.PostID = i.PostID  and p.HouseID = h.HouseID  
		  and p.HouseID = h1.HouseID
	order by w.TimeCreated desc
END
